export function setCookie(key, value, seconds, path = '/') {
    const date = new Date()
    date.setTime(date.getTime() - 8 * 3600 * 1000 + seconds * 1000)
    document.cookie = `${key}=${value};expires=${date};path=${path}`
}

export function getCookie(key) {
    const cookie = document.cookie
    if (cookie === '') {
        return
    }
    const cookiesArr = cookie.split('; ')
    for (let i = 0; i < cookiesArr.length; i++) {
        let brr = cookiesArr[i].split('=')
        if (brr[0] === key) {
            return brr[1]
        }
    }
}

export function removeCookie(key, path = '/') {
    setCookie(key, null, -1, path)
}